package com.stylefeng.guns.rest.modular.jubao.controller;

import com.stylefeng.guns.rest.common.CommonResponse;
import com.stylefeng.guns.rest.common.exception.BizExceptionEnum;
import com.stylefeng.guns.rest.common.exception.BussinessException;
import com.stylefeng.guns.rest.common.persistence.model.Content;
import com.stylefeng.guns.rest.common.utils.TextUtil;
import com.stylefeng.guns.rest.modular.content.controller.dto.AddContentRequest;
import com.stylefeng.guns.rest.modular.content.controller.dto.CommentListRequest;
import com.stylefeng.guns.rest.modular.content.controller.dto.CommentListResponse;
import com.stylefeng.guns.rest.modular.content.controller.dto.ContentData;
import com.stylefeng.guns.rest.modular.content.service.ContentService;
import com.stylefeng.guns.rest.modular.jubao.controller.dto.JubaoRequest;
import com.stylefeng.guns.rest.modular.jubao.service.JubaoService;
import org.apache.commons.logging.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * Created by ASUS-PC on 2018/6/26.
 */
@RestController
@RequestMapping("/jubao")
public class JubaoController {
    private final Log logger = org.apache.commons.logging.LogFactory.getLog(this.getClass());

    @Autowired
    JubaoService jubaoService;

    //添加评论
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResponseEntity<?> queryVersionInfo(@RequestBody JubaoRequest request) {
        if(request.getArtitleId()==0){
            throw new BussinessException(BizExceptionEnum.NEED_PARAMS);
        }
        boolean state = jubaoService.intsert(request);
        if(state){
            return ResponseEntity.ok(CommonResponse.ok(null));
        }
        throw new BussinessException(BizExceptionEnum.UNKNOWN_ERROR);
    }



}
